package com.java.zhuiyun.api.playerinformation.controller;

import com.java.zhuiyun.annotation.OptLog;
import com.java.zhuiyun.api.playerinformation.entity.PlayerInformation;
import com.java.zhuiyun.api.playerinformation.model.AppUser;
import com.java.zhuiyun.api.playerinformation.service.PlayerInformationService;
import com.java.zhuiyun.common.response.CommonConstants;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.config.AuthAccess;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


/**
 * (PlayerInformation)表控制层
 *
 * @author makejava
 * @since 2023-09-14 10:35:40
 */
@RestController
@RequestMapping("/playerInformation")
public class PlayerInformationController {
    /**
     * 服务对象
     */
    @Autowired
    private PlayerInformationService playerInformationService;

    /*
     * @Author wuwan
     * @Description 分页查询
     * @Date 2023/9/14 10:48
     * @Return
     * @param null
     */
    @GetMapping("/selectPlayerInformation")
    @ApiOperation(value = "分页查询")
    @OptLog(modular = "用户管理",type = CommonConstants.SELECT,describe = "分页查询")
    public CommonResult selectPlayerInformation(PageRequest pageRequest,String name){
        return CommonResult.ok(playerInformationService.selectPlayerInformation(pageRequest,name));
    }
    /*
     * @Author wuwan
     * @Description 获取openid
     * @Date 2023/9/14 20:02
     * @Return
     * @param null
     */
    @PostMapping("/getOpenid")
    @ApiOperation(value = "获取openid")
    public CommonResult getOpenid(@RequestBody AppUser code){
        return CommonResult.ok(playerInformationService.getOpenid(code));
    }
    /*
     * @Author wuwan
     * @Description 进入页面刷新最后登录时间
     * @Date 2023/9/18 19:54
     * @Return
     * @param null
     */
    @PostMapping("/uploginTime")
    @ApiOperation(value = "进入页面刷新最后登录时间")
    public CommonResult uploginTime(@RequestBody String openid){
        return CommonResult.ok(playerInformationService.uploginTime(openid));
    }
    /*
     * @Author wuwan
     * @Description 用户角色升级机制
     * @Date 2023/9/20 16:33
     * @Return
     * @param null
     */
    @PostMapping("/roleLevelUp")
    @ApiOperation(value = "用户角色升级机制")
    public CommonResult upPlayerLevel(@RequestBody PlayerInformation playerInformation){
        return CommonResult.ok(playerInformationService.upPlayerLevel(playerInformation));
    }
    /*
     * @Author wuwan
     * @Description 用户房屋升级机制
     * @Date 2023/9/20 16:33
     * @Return
     * @param null
     */
    @PostMapping("/upPlayerHouseLevel")
    @ApiOperation(value = "用户房屋升级机制")
    public CommonResult upPlayerHouseLevel(@RequestBody PlayerInformation playerInformation){
        return CommonResult.ok(playerInformationService.upPlayerHouseLevel(playerInformation));
    }
    /**
     * @Author 杨友朋
     * @Description TODO 单查
     * @Date 2023/9/27 15:52
     * @Return
     */
    @AuthAccess
    @GetMapping("/selectByUserId")
    @ApiOperation(value = "单查")
    public CommonResult selectByUserId(String openId){
        return CommonResult.ok(playerInformationService.selectByUserId(openId));
    }
    /*
     * @Author WX
     * @Description 修改冒险通关次数
     * @Date 2023/10/8 9:39
     * @Return
     * @param openid
     */
    @GetMapping("/updateAdventureIdNumber")
    @ApiOperation(value = "修改冒险通关次数")
    @OptLog(modular = "用户管理",type = CommonConstants.UPDATE,describe = "修改冒险通关次数")
    public CommonResult updateAdventureIdNumber(String openid) {
        return CommonResult.ok(playerInformationService.updateAdventureIdNumber(openid));
    }

    /*
     * @Author WX
     * @Description 根据openid查询出用户的信息数量
     * @Date 2023/9/27 9:38
     * @Return
     * @param openid
     */
    @GetMapping("/queryByUser")
    @ApiOperation(value = "根据openid查询出用户的信息数量")
    @OptLog(modular = "用户管理",type = CommonConstants.SELECT,describe = "根据openid查询出用户的信息数量")
    public CommonResult queryByUser (String openid) {
        return CommonResult.ok(playerInformationService.queryByUser(openid));
    }
    /*
     * @Author wuwan
     * @Description 修改冒险次数
     * @Date 2023/9/27 9:32
     * @Return
     */
    @GetMapping("/queryByOpenId")
    @ApiOperation(value = "修改冒险次数")
    @OptLog(modular = "用户管理",type = CommonConstants.UPDATE,describe = "修改冒险次数")
    public CommonResult queryByOpenId (String openid) {
        return CommonResult.ok(playerInformationService.queryByOpenId(openid));
    }
    /*
     * @Author 杨友朋
     * @Description 下一关
     * @Date 2023/10/11 13:41
     * @Return
     * @param appUser
     */
    @PostMapping("/nextLevel")
    @ApiOperation(value = "下一关")
    public CommonResult nextLevel (@RequestBody AppUser appUser) {
        return playerInformationService.nextLevel(appUser);
    }
    /*
     * @Author WX
     * @Description 冒险通关成功后操作
     * @Date 2023/10/9 10:16
     * @Return
     * @param openid
     */
    @GetMapping("/passingLevelSuccessful")
    @ApiOperation(value = "冒险通关成功后操作")
    @OptLog(modular = "用户管理",type = CommonConstants.UPDATE,describe = "冒险通关成功后操作")
    public CommonResult passingLevelSuccessful (String openid) {
        return CommonResult.ok(playerInformationService.passingLevelSuccessful(openid));
    }

    /*
    * @Author WX
    * @Description 冒险通一个小关卡操作
    * @Date 2023/10/17 8:58
    * @Return
    * @param id
    */
    @GetMapping("/adventurePassOneLevelOperation")
    @ApiOperation(value = "冒险通一个小关卡操作")
    @OptLog(modular = "用户管理",type = CommonConstants.UPDATE,describe = "冒险通一个小关卡操作")
    public CommonResult adventurePassOneLevelOperation (int id) {
        return CommonResult.ok(playerInformationService.adventurePassOneLevelOperation(id));
    }
    /**
    * @Author MJL
    * @Description todo 看图猜成语关卡机制   
    * @Date 2023/10/19 9:58
    * @Return  * @param null
    */
    @PostMapping("/pictureLevelUp")
    @ApiOperation(value = "看图猜成语关卡机制")
    public CommonResult pictureLevelUp(@RequestBody PlayerInformation playerInformation){
        return CommonResult.ok(playerInformationService.pictureLevelUp(playerInformation));
    }

    /**
    * @Author 杨友朋
    * @Description TODO 成语接龙通一个小关卡操作
    * @Date 2023/10/20 9:38
    * @Return CommonResult
    * @param id,correctlyAnsweredQuestions,correctlyAnsweredWord
    */
    @GetMapping("/idiomGOGOGO")
    @ApiOperation(value = "成语接龙通一个小关卡操作")
    @OptLog(modular = "用户管理",type = CommonConstants.UPDATE,describe = "成语接龙通一个小关卡操作")
    public CommonResult idiomGOGOGO (int id,Integer correctlyAnsweredQuestions,Integer correctlyAnsweredWord) {
        return playerInformationService.idiomGOGOGO(id,correctlyAnsweredQuestions,correctlyAnsweredWord);
    }
}

